<#assign domain="${ctx.contextPath}" />
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
	<meta name="renderer" content="webkit">
	<title>changPassword</title>
	<link rel="stylesheet" href="${domain}/static/css/common/base.css">
	<link rel="stylesheet" href="${domain}/static/css/bootstrap.min.css">
	<link rel="stylesheet" href="${domain}/static/css/common/header.css">
	<link rel="stylesheet" href="${domain}/static/css/changePassword.css">
	<script src="${domain}/static/js/jquery-3.2.1.slim.min.js"></script>
	<script src="${domain}/static/js/bootstrap.min.js"></script
</head>
<body>
	<!--头部导航-->

	<div class="content">
	<!--侧边导航-->

	<!--修改密码内容-->
		<div class="changePassword">
			<div class="wrap">
            <h1>修改密码</h1>
            	<div class="form-group">
					<input type="password" class="form-control" placeholder="原始密码" id="password">
					<span id="pwdText"></span>
				</div>
				<div class="form-group">
					<input type="password" class="form-control" placeholder="新密码" id="newPassword">
					<span id="newPwdText"></span>
				</div>
				<div class="form-group">
					<input type="password" class="form-control" placeholder="确认密码"  id="confrimPassword">
					<span id="confrimPwdText"></span>
				</div>
          		<div c name="signup">
          			<button name="signup" value="Sign up" class="look" id="signup">修改</button>
		  		</div>
			</div>
		</div>
	</div>
</body>

<script type="text/javascript">

    var domain ='${domain}';
	
	$("#signup").click(function(){
	
	var password = $('#password').val();
	var newPassword =$("#newPassword").val();
	var confrimPassword = $('#confrimPassword').val();
	
	password  = $.trim($("#password").val());
	if(password==''||name==null||name==undefined){
		$("#pwdText").html("原密码不能为空！");
		$("#pwdText").css({"color":"#F00"});
		return false;
	}
	
	newPassword  = $.trim($("#newPassword").val());
	if(newPassword==''||newPassword==null||newPassword==undefined){
		$("#newPwdText").html("新密码不能为空！");
		$("#newPwdText").css({"color":"#F00"});
		return false;
		
	}else if(password==newPassword){
			$('#newPwdText').text("新密码和初始密码相同，请重新输入！");
			$("#newPwdText").css({"color":"#F00"});
			return false;
	}

	confrimPassword  = $.trim($("#confrimPassword").val());
	if(confrimPassword==''||confrimPassword==null||confrimPassword==undefined){
		$("#confrimPwdText").html("确认密码不能为空！");
		$("#confrimPwdText").css({"color":"#F00"});
		return false;
	}
	
	if(newPassword==confrimPassword){
	
	       var jsonData = {
		         "pwd":password,
		         "newPwd":newPassword
		   };

		$.ajax({
						type : 'POST',
						url : domain+'/updateUserByPwd',
						data : jsonData,
						dataType : 'json',
						success : function(data) {
							if(data.success){
							      top.location.href = domain+'/index'; 
						    }else{
						      $('#pwdText').text(data.msg);
						      $("#pwdText").css({"color":"#F00"});
						    }
						}
				});
	}else{
		$('#confrimPwdText').text("确认密码和新密码不同，请重新输入！");
		$("#confrimPwdText").css({"color":"#F00"});
	}
});
   
</script>
</html>